/*
 * File     : Symbol.java
 * Created  : 22 Apr 2011
 *
 * Copyright © 2011 Matthew Wilson (mj. {my-surname} .uk {at} gmail.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.googlecode.dni.library;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.googlecode.dni.type.structure.Structure;
import com.googlecode.dni.type.utility.IntStructure;


/**
 * <p>
 *  Annotates a method of a native interface that maps to a native symbol
 *  defined in the library.
 * </p>
 * <p>
 *  Many C libraries define global constants or variables.  These are simply
 *  symbol names in the library in the same way as functions are (with a
 *  different type).  <code>Symbol</code> allows you to read and write these
 *  values with Java getters and setters as in {@link Structure}s.
 * </p>
 * <p>
 *  The rules for the methods are as defined in {@link Structure}.  A setter is
 *  optional.  Both the getter and setter (if present) must be annotated with
 *  {@link Symbol}.  The symbol's name, by default, is taken from the getter's
 *  name.
 * </p>
 * <h4>Example</h4>
 * <pre>
 *  // int GlobalInt;
 *  // -- mutable, hence both getter and setter
 *  &#64;Symbol int getGlobalInt();
 *  &#64;Symbol void setGlobalInt( int globalInt );
 *
 *  // const int* GlobalIntPtr;
 *  // -- immutable, hence only getter
 *  &#64;Symbol {@link IntStructure} getGlobalIntPtr();
 *
 *  // struct X GlobalStruct;
 *  // -- structure itself is mutable, hence only getter
 *  &#64;Symbol X getGlobalStruct();
 *
 *  // struct X* GlobalStructPtr;
 *  // -- mutable, hence both getter and setter
 *  &#64;Symbol X getGlobalStructPtr();
 *  &#64;Symbol void setGlobalStructPtr( X globalStructPtr );
 * </pre>
 *
 * @author Matthew Wilson
 */
@Retention( RetentionPolicy.RUNTIME )
@Target( ElementType.METHOD )
@Documented
public @interface Symbol
{

    /**
     * <p>
     *  The native name of the symbol.
     * </p>
     * <p>
     *  The default name (if this property is not set) will be taken from the
     *  method name.
     * </p>
     * <p>
     *  The {@linkplain Library#symbolPrefix() library's symbol name prefix} is
     *  not applied to this name.
     * </p>
     *
     * @return the name, or an empty string to use the default name
     */
    String name() default "";

}
